package com.isunland.managesystem.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.isunland.managesystem.R;
import com.isunland.managesystem.entity.CustomerMainOriginal.rCustomerMain;
import java.util.List;

public class CustomersRelationListAdapter extends ArrayAdapter<rCustomerMain> {

  /**
   * ViewHolder class for layout.<br />
   * <br />
   * Auto-created on 2015-08-04 14:52:10 by Android Layout Finder
   * (http://www.buzzingandroid.com/tools/android-layout-finder)
   */
  private static class ViewHolder {
    public final RelativeLayout rootView;
    public final TextView tvCustomerNameCustomerListAdapter;
    public final TextView tvCustomerDicritCustomerListAdapter;
    private final TextView tvIsDraft;

    private ViewHolder(RelativeLayout rootView, TextView tvCustomerNameCustomerListAdapter,
        TextView tvCustomerDicritCustomerListAdapter, TextView tvIsDraft) {
      this.rootView = rootView;
      this.tvCustomerNameCustomerListAdapter = tvCustomerNameCustomerListAdapter;
      this.tvCustomerDicritCustomerListAdapter = tvCustomerDicritCustomerListAdapter;
      this.tvIsDraft = tvIsDraft;
    }

    public static ViewHolder create(RelativeLayout rootView) {
      TextView tvCustomerNameCustomerListAdapter =
          (TextView) rootView.findViewById(R.id.tv_customerName_customerListAdapter);
      TextView tvCustomerDicritCustomerListAdapter =
          (TextView) rootView.findViewById(R.id.tv_customerDicrit_customerListAdapter);
      TextView tvIsDraft = (TextView) rootView.findViewById(R.id.tv_isDraft_customerListAdapter);
      return new ViewHolder(rootView, tvCustomerNameCustomerListAdapter,
          tvCustomerDicritCustomerListAdapter, tvIsDraft);
    }
  }

  @Override public View getView(int position, View convertView, ViewGroup parent) {
    final ViewHolder vh;
    if (convertView == null) {
      View view = mInflater.inflate(R.layout.adapter_customer_list, parent, false);
      vh = ViewHolder.create((RelativeLayout) view);
      view.setTag(vh);
    } else {
      vh = (ViewHolder) convertView.getTag();
    }

    rCustomerMain item = getItem(position);

    vh.tvCustomerNameCustomerListAdapter.setText(
        mContext.getString(R.string.customer_manage_name, item.getCustomerName()));
    vh.tvCustomerDicritCustomerListAdapter.setText(
        mContext.getString(R.string.customer_manage_district, item.getDistrictDesc()));

    return vh.rootView;
  }

  private LayoutInflater mInflater;
  private Context mContext;

  // Constructors
  public CustomersRelationListAdapter(Context context, List<rCustomerMain> customerDetails) {
    super(context, 0, customerDetails);
    this.mInflater = LayoutInflater.from(context);
    this.mContext = context;
  }

  public CustomersRelationListAdapter(Context context, rCustomerMain[] objects) {
    super(context, 0, objects);
    this.mInflater = LayoutInflater.from(context);
  }
}
 


